package com.zzyl.controller;

import com.zzyl.base.ResponseResult;
import com.zzyl.dto.LoginDto;
import com.zzyl.service.LoginService;
import com.zzyl.vo.UserVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/security")
@Api(tags = "用户登录")
public class LoginController {

    @Autowired
    private LoginService loginService;
    /**
     * 登录接口方法
     * @param dto  请求参数
     *
     * @return 第一种  ResponseResult<Map>
     *     Map map=new HashMap();
     *     map.put("user",user);
     *     map.put("userToken",token)
     *     ResponseResult.sucess(map)
     *      第二种，ResponseResult<UserVo>
     */
    @PostMapping("/login")
    @ApiOperation(value = "用户登录",notes = "用户登录")
    public ResponseResult<UserVo> login(@RequestBody LoginDto dto){
        return loginService.login(dto);
    }
}
